package io.sqrtqiezi.spark.streaming

import java.io.PrintWriter
import java.net.ServerSocket

object SocketLikeNCWithWindow {
  def main(args: Array[String]): Unit = {
    val port = 1521
    val ss = new ServerSocket(port)
    val socket = ss.accept()

    println("connect to host : " + socket.getInetAddress)

    var i = 0;
    while (true) {
      i += 1
      val out = new PrintWriter(socket.getOutputStream)
      out.println(i)
      out.flush()
      Thread.sleep(1000)
    }
  }
}
